<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="C" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <!-- 引入Bootstrap核心文件 -->
    <link href="css/bootstrap.min.css" rel="stylesheet">

    <!-- jQuery(Bootstrap的JavaScript插件需要引入jQuery，务必在bootstrap.min.js之前引入) -->
    <script src="js/jquery.min.js"></script>

    <!-- 包括所有已编译的JS插件 -->
    <script src="js/bootstrap.min.js"></script>

</head>

<body>
<div class="container" style="font-family:微软雅黑;font-size:larger">
    <div class="page-header">
        <h2 align="center">新闻列表</h2>
    </div>

    <div class="col-md-offset-1 col-md-10">
        <form action="/goto_index" method="post" class="navbar-form navbar-left" role="search">
            <div class="form-group">
                新闻标题：
                <input type="text" name="name" class="form-control">
            </div>
            &nbsp;
            <div class="form-group">
                发布时间：
                <input type="text" name="beginTime" class="form-control"> -
                <input type="text" name="endTime" class="form-control">
            </div>
            &nbsp;
            <div class="form-group">
                <button type="submit" class="btn btn-default">
                   查询
                </button>
            </div>
        </form>

        <table class="table table-bordered">
            <thead>
            <tr align="center">
                <td>新闻编号</td>
                <td>新闻标题</td>
                <td>作者</td>
                <td>发布时间</td>
                <td>新闻内容</td>
                <td>浏览量</td>
                <td>操作</td>
            </tr>
            </thead>
            <C:forEach items="${newsPage.newsList}" var="n">
                <tr>
                    <td>${n.id}</td>
                    <td>${n.title}</td>
                    <td>${n.name}</td>
                    <td>
                        <fmt:formatDate value="${n.time}" pattern="yyyy-MM-dd"/>
                    </td>
                    <td>${n.content}</td>
                    <td name="vie">${n.views}</td>
                    <td>
                        <a href="/goto_news?id=${n.id}" target="_blank">查看新闻</a>
                    </td>
                </tr>
            </C:forEach>

        </table>

        <div align="center">
            <nav>
                <ul class="pagination">
                    <c:if test="${newsPage.pageNum == 1}">
                        <li class="disabled"><a href="javascript:void(0);">首页</a></li>
                    </c:if>
                    <c:if test="${newsPage.pageNum > 1}">
                        <li><a href="/goto_index?page=1&size=${newsPage.pageSize}">首页</a></li>
                    </c:if>
                    <li class="disabled"><a href="javascript:void(0);" aria-label="Previous"><span aria-hidden="true">&laquo;</span></a></li>
                    <c:forEach begin="1" end="${newsPage.pageCount}" var="i">
                        <c:if test="${newPage.pageNum == i}">
                            <li class="active"><a href="#">${i}</a></li>
                        </c:if>
                        <c:if test="${newPage.pageNum != i}">
                            <li><a href="/goto_index?page=${i}&size=${newsPage.pageSize}">${i}</a></li>
                        </c:if>
                    </c:forEach>
                    <li><a href="#" aria-label="Next"><span aria-hidden="true">&raquo;</span></a></li>
                    <c:if test="${newsPage.pageNum == newsPage.pageCount}">
                        <li class="disabled"><a href="#">末页</a></li>
                    </c:if>
                    <c:if test="${newsPage.pageNum < newsPage.pageCount}">
                        <li><a href="/goto_index?page=${newsPage.pageCount}&size=${newsPage.pageSize}">末页</a></li>
                    </c:if>
                </ul>
            </nav>
        </div>

    </div>
</div>
</body>
</html>
